#include <QtGui/QApplication>
#include "tetrix.h"

#include "../TetrixServer/protosrvmanager.h"
#include "../TetrixServer/createroomreq.h"
#include "../TetrixServer/createroomresp.h"
#include "../TetrixServer/getroomlistreq.h"
#include "../TetrixServer/getroomlistresp.h"
#include "../TetrixServer/enterroomsrv.h"
#include "../TetrixServer/leaveroomreq.h"

void registerAllProtoSrv()
{
    ProtoSrvManager::getInstance()->registerProtoSrv(new CreateRoomResp());
    ProtoSrvManager::getInstance()->registerProtoSrv(new GetRoomListResp());
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_RESP_ENTER_ROOM));
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_RESP_LEAVE_ROOM));
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_RESP_STATUS_SET));
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_NOTIFY_CREATE_ROOM));
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_NOTIFY_ENTER_ROOM));
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_NOTIFY_LEAVE_ROOM));
    ProtoSrvManager::getInstance()->registerProtoSrv(new SimpleProtoSrv(PT_NOTIFY_GAME_START));
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    registerAllProtoSrv();

    Tetrix w;
    w.show();

    if(!w.start()){
        ACE_DEBUG((LM_ERROR,"Start Fail\n"));
        return 0;
    }

    return a.exec();
}
